Business Analytics

Quarto - Literate Programming

Ayush Patel

16 January, 2024

Pre-requisite

You should have

  • RStudio installed
  • Quarto installed
  • tinytex installed
  • rmarkdown installed

About Me

I am Ayush.

I am a researcher working at the intersection of data, law, development and economics.

I teach Data Science using R at Gokhale Institute of Politics and Economics

I am a RStudio (Posit) certified tidyverse Instructor.

I am a Researcher at Oxford Poverty and Human development Initiative (OPHI), at the University of Oxford.

Reach me

ayush.ap58@gmail.com

ayush.patel@gipe.ac.in

Quarto - Literate Programming

“A data science authoring framework”

Bind code, its output and your words in one document.

Quarto

  • .qmd files
  • can be rendered to various formats - pdf, word, html, presentations etc.
  • can run multiple languages - R, Python, Julia etc

Essential elements of a Quarto doc

  • The YAML header - stuff between --- at the begining of the doc
  • Code chunks - code written between ```
  • Your words and explanations in text and simple markdown formatting *Italic* **Bold**

Quarto Components - The YAML

Yet Another Markup Language


---
title: "Mirza Nosha and Economics"
subtitle: "What iffs"
author: "Ayush"
date: "Jan 16, 2024"
format: html
---
  • Controls the meta settings
  • It is optional
  • Comes with predefined defaults
  • See other options here

Quarto Components - Code Chunks

```{r}
#| eval: false
#| label: chunk1
#| fig-width: 6

2+2
```
  • This is where you write your code
  • There can be multiple code chunks
  • the stuff that follows after #| is chunk option. See to learn more.
  • see Tools>Keybord shortcuts help to find shortcut to create a code chunk.

Quarto Components - text & formatting

# heading

*Italics*

$$Y = \alpha + \beta x + \epsilon$$

Heading

Italics

\[Y = \alpha + \beta x + \epsilon\]

See for more on markdown reference

What can go wrong? - Render a qmd

  • File> New File> Quarto Document
  • Add title, author name and select output type
  • Click Create
  • This is a .qmdfile
  • Find the blue Render button, Press it.
  • Are you able to see an output file?

You just rendered your first Quarto file

Quarto Documentation

No one can remember everything. Refer to documentation. Do yourself a favour.

A small demo

Exercise

  • Create a Quarto document set for html output
  • Provide appropriate title
  • Add you name to author
  • Refer to Diwali Sales Data code book
  • Use this command to read in the data:
data_diwali <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-11-14/diwali_sales_data.csv")

Carry out Exploratory and Descriptive Analyses. Write about your observations.

Thank you.